#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
typedef struct BinaryTreeNode
{
	struct BinaryTreeNode* left;
	struct BinaryTreeNode* right;
	int val;
}BTNode;

BTNode* BuyBTNode(int x)
{
	BTNode* newnode = (BTNode*)malloc(sizeof(BTNode));
	newnode->val = x;
	newnode->left = NULL;
	newnode->right = NULL;
	return newnode;
}
bool isSameTree(BTNode* root1, BTNode* root2)
{
	//全空
	if (root1 == NULL && root2 == NULL)
	{
		return true;
	}
	//有一个空
	if (root1 == NULL || root2 == NULL)
	{
		return false;
	}
	//值不相等
	if (root1->val != root2->val)
	{
		return false;
	}

	return isSameTree(root1->left, root2->left)
		&& isSameTree(root1->right, root2->right);

}

int main()
{
	BTNode* node1 = BuyBTNode(1);
	BTNode* node2 = BuyBTNode(2);
	BTNode* node3 = BuyBTNode(3);

	BTNode* node4 = BuyBTNode(1);
	BTNode* node5 = BuyBTNode(2);
	BTNode* node6 = BuyBTNode(3);
	
	node1->left = node2;
	node1->right = node3;

	node4->left = node5;
	node4->right = node6;

	 bool ret = isSameTree(node1, node4);
	 if (ret == true)
	 {
		 printf("true");
	 }
	 else
	 {
		 printf("false");
	 }

	return 0;
}